<template>
	<div class="voteactivity">
		<div class="title">
			{{detail.title}}
		</div>
		<div class="from">
			<span>发起人：{{detail.resource}}</span>
			<span>时间：{{detail.starttime_text}}</span>
			<span>浏览：{{detail.browse}}次</span>
		</div>
		<van-divider />
		<div class="content">
			<div class="text" v-html="detail.child_vote.votecontent"></div>

			<div class="zan" @click="toupiao(1)">
				<van-icon name="good-job-o" />赞同({{detail.child_vote.agree}})
			</div>
			<div class="zan fan" @click="toupiao(2)">
				<van-icon name="good-job-o" />反对({{detail.child_vote.against}})
			</div>
			<!-- <div class="zan" v-if="detail.child_vote.typedata">
				<van-icon name="good-job-o" />赞同({{detail.child_vote.agree}})
			</div>
			<div class="zan fan" v-if="detail.child_vote.typedata">
				<van-icon name="good-job-o" />反对({{detail.child_vote.against}})
			</div> -->
		</div>
	</div>
</template>

<script>
	export default {
		name: "VoteActivity",
		components: {

		},
		data() {
			return {
				detail: {
					child_vote: {
						votecontent: ''
					}
				},
				userInfo:{}
			}
		},
		mounted() {
			this.userInfo =JSON.parse(this.$getcookie("userInfo"))
			this.getData()
		},
		methods: {
			getData() {
				let detailData = {
					user_id:this.userInfo.user_id,
					token: this.$getcookie("jy_token"),
					site_id: 0,
					vote_id: this.$route.query.id
				}
				this.$api.home.activeVoteDetail(detailData).then(res => {
					// 执行某些操作
					if (res.code == 1) {
						this.detail = res.data
					}

				})
			},
			toupiao(type){
				let detailData = {
					user_id:this.userInfo.user_id,
					token: this.$getcookie("jy_token"),
					site_id: 0,
					vote_id: this.$route.query.id,
					child_vote_id: this.detail.child_vote.id,
					typedata: type,
				}
				this.$api.home.activeVoteBet(detailData).then(res => {
					// 执行某些操作
					if (res.code == 1) {
						this.$toast.success(res.msg)
						this.getData()
					}else{
						this.$toast.fail(res.msg)
					}
				
				})
			}
		}


	}
</script>

<style lang="less">
	.voteactivity {
		padding: 1.13rem 0.78rem;
		background: #fff;

		.title {
			font-size: 0.94rem;
			font-family: PingFang SC;
			font-weight: bold;
			color: rgba(38, 38, 38, 1);
		}

		.from {
			font-size: 0.69rem;
			font-family: PingFang SC;
			font-weight: 500;
			color: rgba(147, 147, 147, 1);
			margin-top: 1rem;
			display: flex;
			justify-content: space-between;
		}

		.content {
			.text {
				font-size: 0.81rem;
				font-family: PingFang SC;
				font-weight: 500;
				color: rgba(54, 54, 54, 1);
				line-height: 1.25rem;
				margin-top: 1.81rem;
			}

			.zan {
				width: 16.88rem;
				height: 2.81rem;
				background: rgba(254, 119, 0, 1);
				border-radius: 2rem;
				display: flex;
				justify-content: center;
				align-items: center;
				font-size: 0.94rem;
				font-family: PingFang SC;
				font-weight: 500;
				color: rgba(255, 255, 255, 1);
				margin: 1rem auto;

				.van-icon-good-job-o {
					margin-right: 0.47rem;
				}

				&.fan {

					opacity: 0.5;

					.van-icon-good-job-o {
						transform: rotate(180deg);
					}
				}

				&.active {
					background: #999;
				}
			}
		}
	}
</style>
